package com.kugou.miniapp.dao;

import com.kugou.miniapp.domain.Admin;
import com.kugou.miniapp.domain.Friend;
import com.kugou.miniapp.domain.Users;
import org.apache.catalina.LifecycleState;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {

    @Select("select count(*) from admin where password = #{password}")
    public int getAdminByPassword(String password);

    @Update("update users set nick_name = #{nick_name},avatar = #{avatar} where user_id = #{user_id}")
    public int updateUser(Users user);

    public List<Friend> getFriendByUserId(String user_id);

    @Select("select * from users limit #{param1}, 1")
    public Users getRandomOneUser(int index);

    @Select("select count(*) from users")
    public int getUsersCount();

//    @Select("select *from users")
    public List<Users> getAllUsers();

    @Insert("insert into friend (user_id_1, user_id_2) values(#{param1}, #{param2})")
    public int insertFriend(String user_id_1,String user_id_2);

    @Select("select user_id, nick_name, avatar from users where user_id = #{user_id}")
    public Users getUserByUserId(String user_id);

    @Insert("insert into users (user_id, avatar, nick_name) values(#{user_id}, #{avatar}, #{nick_name})")
    public int insertUser(Users user);

    public List<Users> getUserAndMusicList();

    int delFriend(Map<String, Object> con);
}
